package com.jjy.admin.controller.common;

import com.jjy.admin.service.common.CommonService;
import com.jjy.common.annotation.ApiResource;
import com.jjy.common.domain.R;
import com.jjy.common.enums.ResBizTypeEnum;
import com.jjy.admin.domain.Industry;
import com.jjy.admin.domain.JobArea;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * 通用方法
 *
 * @author jjy
 */
@RestController
@RequestMapping("/common/utils")
@ApiResource(name = "通用方法", resBizType = ResBizTypeEnum.SYSTEM)
public class CommonController {
    @Autowired
    private CommonService commonService;

    /**
     * 分页
     */
    @GetMapping("listProvince")
    @PreAuthorize("@ss.hasPermi('common:utils:listProvince')")
    public R listProvince() {
        ArrayList<JobArea> jobAreas = commonService.getProvinces();

        return R.ok().put(jobAreas);
    }

    @GetMapping("listCity/{provinceId}")
    @PreAuthorize("@ss.hasPermi('common:utils:listCity')")
    public R listCity(@PathVariable("provinceId") String provinceId) {
        ArrayList<JobArea> jobAreas = commonService.getCitys(provinceId);

        return R.ok().put(jobAreas);
    }

    /**
     * 查询行业
     */
    @GetMapping("listIndustry")
    @PreAuthorize("@ss.hasPermi('common:utils:listIndustry')")
    public R listIndustry() {
        ArrayList<Industry> jobAreas = commonService.getIndustry();

        return R.ok().put(jobAreas);
    }

  /**
     * 查询热门城市
     */
    @GetMapping("searchHotCity")
    @PreAuthorize("@ss.hasPermi('common:utils:searchHotCity')")
    public R searchHotCity() {
        ArrayList hotCity = commonService.searchHotCity();

        return R.ok().put(hotCity);
    }

}